package com.danieldura.highrise.requests
{
	import com.danieldura.highrise.HighriseCredentials;
	import com.danieldura.highrise.data.Comment;
	
	public class CommentsRequest extends HighriseRequest
	{
		
		public function CommentsRequest( credentials:HighriseCredentials )
		{
			super( credentials, new HighriseRequestDataMap( "comment", "comments", Comment ) );
		}
		
		public function show( id:int ):void
		{
			requestMethod = URLRequestMethod.GET;
			location = "/comments/" + id + format;
			send();			
		}
		
		public function listAllFromNote( noteId:int ):void
		{
			requestMethod = URLRequestMethod.GET;
			location = "/notes/" + id + "/comments" + format;
			send();			
		}
		
		public function listAllFromEmail( emailId:int ):void
		{
			requestMethod = URLRequestMethod.GET;
			location = "/emails/" + id + "/comments" + format;
			send();			
		}
		
		public function create( comment:Comment ):void
		{
			requestMethod = URLRequestMethod.POST;
			location = "/comments.xml";
			requestData = comment.toXMLString();
			send();
		}
		
		public function update( comment:Comment ):void
		{
			requestMethod = "PUT";
			location = "/comments/" + id + ".xml";
			requestData = comment.toXMLString();
			send();			
		}
		
		public function destroy( comment:Comment ):void
		{
			requestMethod = "DELETE";
			location = "/comments/" + id + ".xml";
			send();
		}
				
	}
}